package cn.glutnn.service.impl;

import cn.glutnn.entity.PurchaseDetail;
import cn.glutnn.entity.Result;
import cn.glutnn.mapper.PurchaseMapper;
import cn.glutnn.service.PurchaseService;
import cn.glutnn.utils.ThreadLocalUtil;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import cn.glutnn.entity.Purchase;

import java.util.List;
import java.util.Map;

/**
 * (Purchase)表服务实现类
 *
 * @author msh
 * @since 2024-10-25 09:35:25
 */
@Service
public class PurchaseServiceImpl extends ServiceImpl<PurchaseMapper, Purchase> implements PurchaseService {
    @Autowired
    private PurchaseMapper purchaseMapper;
    @Override
    public Result<List<Purchase>> selectByPurchaseType() {
        QueryWrapper<Purchase> ew = new QueryWrapper<>();
        Map o = ThreadLocalUtil.get();
        ew.eq("own_name",o.get("username"));
        List<Purchase> list = list(ew);
        System.out.println(list);
        return Result.success(list);
    }

    @Override
    public void saveAndGetId(Purchase purchase) {
         purchaseMapper.insertPurchase(purchase);
    }


}

